import HttpUtil from '@/common/HttpUtil'

const templateApi = {
  findTemplatePage (params) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/template/findTemplatePage'
    return HttpUtil.postJSON(postUrl, params)
  },
  addTemplate (params) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/template/addTemplate'
    return HttpUtil.postJSON(postUrl, params)
  },
  updateTemplate (params) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/template/updateTemplate'
    return HttpUtil.putJSON(postUrl, params)
  },
  getTemplate (param) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/template/getTemplate/' + param
    return HttpUtil.get(postUrl, null)
  },
  deleteTemplate (param) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/template/deleteTemplate/' + param
    return HttpUtil.delete(postUrl, null)
  },
  saveTemplateItem (params) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/templateItem/saveItem'
    return HttpUtil.postJSON(postUrl, params)
  },
  deleteTemplateItem (param) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/templateItem/deleteItem/' + param
    return HttpUtil.delete(postUrl, null)
  },
  getTemplateItem (param) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/templateItem/getItem/' + param
    return HttpUtil.get(postUrl, null)
  },
  findTemplateItemPage (params) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/templateItem/findItemPage'
    return HttpUtil.postJSON(postUrl, params)
  },
  findTemplateItem (params) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/templateItem/findItem'
    return HttpUtil.post(postUrl, params)
  },
  findTemplate (param) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/template/findTemplate'
    return HttpUtil.postJSON(postUrl, {module: param})
  },
  findUnityLibData (param) {
    let postUrl = process.env.SURVEY_DOMAIN + '/unity3d/api/findModelLib'
    return HttpUtil.get(postUrl, null)
  },
  findTemplateByName (param) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/template/findTemplateByName?name=' + param
    return HttpUtil.post(postUrl, null)
  },
  findColumn(id) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/template/findColumn/' + id
    return HttpUtil.get(postUrl, null)
  },
  findItem(params) {
    let postUrl = process.env.SURVEY_DOMAIN + '/ws/templateItem/findAll'
    return HttpUtil.postJSON(postUrl, params)
  }
}

export default templateApi
